/**
 * Created by Administrator on 2016/6/30.
 */
$(function () {
    //添加商家
    var _n = 1;
    $(".Jaddshoplist").click(function () {
        var html = '';
        html += '<div class="control-group  act-border">' +
            '<div class="control-group sort-back"> ' +
            '<div class="controls text-center act-add-del Jshopinfo">' +
            '<label class="Jshopdelete"><span class="JsortList text-left"><input type="hidden" class="sortNum" value="' + _n + '"></span>' +
            '<span class="down-list">第 <input type="text"  class="sort-info" style="width: 80px" data-require="1"> 个显示</span><span class="view-list" style="cursor: pointer">&nbsp;删除</span></label>' +
            '</div></div> ' +
            '<div class="control-group Branch"> ' +
            '<label class="control-label">商家分店：</label>' +
            '<div class="controls"> ' +
            '<input type="text" name="ShopId" class="shopid" data-require="1"> ' +
            '<span class="form-required">*</span>' +
            '<div class="Branchlist2"> <select multiple class="form-control Branchlist" style="height:200px"> </select></div>' +
            '</div></div> ' +
            '<div class="control-group"> ' +
            '<label class="control-label">商家分店文案标题：</label> ' +
            '<div class="controls"> ' +
            '<input type="text" name="ShopTitle" class="shoptitle"  data-require="1" maxlength="20"> ' +
            '<span class="form-required">*</span> ' +
            '</div> </div> ' +
            '<div class="control-group">' +
            '<label class="control-label">商家分店文案详情：</label>' +
            '<div class="controls">' +
            '<textarea name="ShopDesc" class="form-control shopdesc"  rows="3" maxlength="400" placeholder="不得超过400个字符"></textarea>' +
            '</div></div>' +
            '<div class="control-group">' +
            '<label class="control-label">标签：</label>' +
            '<div class="controls">' +
            '<input type="text" name="ShopTag" class="form-control shopTag" data-require="1"><span style="color:red">不要超过60个字符，添加格式英文逗号分隔 : 明星,包厢</span>' +
            '</div></div>' +
            '<div class="control-group">' +
            '<label class="control-label">上传图片</label>' +
            '<div class="controls">' +
            '<div id="coverImgInfo">' +
            '<form id="imgForm" action="' + ajaxPic + '" method="post"enctype="multipart/form-data">' +
            '<input type="file" id="coverImg" name="coverImg" accept="image/*" onChange="coverImgChange(this);">' +
            '<span id="coverShopImg"></span></form>' +
            '<input type="hidden" name="ShopPic" class="shoppic" id="shoppic" data-require="1">' +
            '<span class="form-required" >*</span> ' +
            '</div>' +
            '</div>' +
            '</div>' +
            '<div class="control-group">' +
            '<label class="control-label">显示业务类型：</label>' +
            '<div class="controls">' +
            '<span><input type="radio" class="radioOne" name="shopfollow' + _n + '" value="1" disabled><i class="shop-follow">排队取号</i></span>&nbsp;&nbsp;&nbsp;&nbsp;' +
            '<span><input type="radio" class="radioSix" name="shopfollow' + _n + '" value="6" disabled><i class="shop-book">预约订座</i></span>' +
            '</div></div>';

        $(".Jshoplist").append(html);
        $('.busnum').text(_n);
        _n++;
    })


    //添加专题链接
    var j = 1;
    $('.JaddSpeciallist').click(function () {
        var html = '';
        console.log(j);
        if (j > 6) {
            standardTips('最多添加6个');
            return false;
        }
        html += '<div class="control-group  act-special">' +
            '<div class="controls text-center  ">' +
            '<label class="Jshopdelete">' +
            '<span class="view-list" style="cursor: pointer">&nbsp;删除</span></label>' +
            '</div> ' +
            '<div class="control-group">' +
            '<label class="control-label">上传大图片</label>' +
            '<div class="controls">' +
            '<div class="coverBigImgInfo">' +
            '<form class="setBigLinkForm" action="' + coverBigImg + '" method="post" enctype="multipart/form-data">' +
            '<input type="file" id="coverImg" name="coverBigImg" accept="image/*" onChange="coverImgChangeBigLink(this);">' +
            '<span class="coverbiglinkFormImg"></span></form>' +
            '<span class="form-required" >*</span> ' +
            '</div>' +
            '</div>' +
            '</div>' +
            '<div class="control-group">' +
            '<label class="control-label">上传小图片</label>' +
            '<div class="controls">' +
            '<div class="coverSmallImgInfo">' +
            '<form class="setSmallLinkForm" action="' + coverSmallImg + '" method="post"enctype="multipart/form-data">' +
            '<input type="file" id="coverImg" name="coverSmallImg" accept="image/*" onChange="coverImgChangeSmallLink(this);">' +
            '<span class="coverSmalllinkFormImg"></span></form>' +
            '<span class="form-required" >*</span> ' +
            '</div>' +
            '</div>' +
            '</div>' +
            '<div class="control-group">' +
            '<label class="control-label">专题活动链接：</label>' +
            '<div class="controls">' +
            '<input type="text" name="linkUrl" class="linkUrl">' +
            '</div></div>';
        $(".Jspeclist").append(html);
        $('.specNum').text(j);
        j++;
    })
    //删除推荐专题
    $(".Jspeclist").on('click', '.act-special .view-list', function () {
        var _obj = $(this);
        standardConfirm('确定删除', function () {
            _obj.parents('.act-special').remove();
            var specNum = $('.specNum').text();
            var specNu = specNum - 1;
            $('.specNum').text(specNu);
            if (specNu == 0) {
                j = 1;
            } else {
                j = specNu + 1;
            }
        })
    })

    //删除商家
    $(".Jshoplist").on('click', '.Jshopdelete .view-list', function () {
        var _obj = $(this);
        standardConfirm('确定删除', function () {
            _obj.parents('.act-border').remove();
            var _num = $('.busnum').text();
            var _nu = _num - 1;
            $('.busnum').text(_nu);
            if (_nu == 0) {
                _n = 1;
            } else {
                _n = _nu + 1;
            }
        })
    })

    //上移和下移操作
    $(".Jshoplist").on('click', '.Jshopdelete .Jadddown', function () {
        var _obj = $(this), _parentNode, _length, _num;
        _parentNode = _obj.parents('.act-border');

        //把自己放到下一个后面
        _parentNode.next().after(_parentNode);

        _length = _obj.parents('.Jshoplist').find('.act-border').length;

        //遍历，重新排序
        $('.Jshoplist .Jshopdelete .JsortList').each(function (i, n) {
            _num = _length - i;
            console.log(_num);
            $(this).parent('.Jshopdelete').find('.sortNum').val(_num);
        })

    })

    $(".Jshoplist").on('click', '.Jshopdelete .Jaddup', function () {
        var _obj = $(this), _parentNode, _length, _num;

        _parentNode = _obj.parents('.act-border');

        _parentNode.prev().before(_parentNode);

        _length = _obj.parents('.Jshoplist').find('.act-border').length;

        //遍历，重新排序
        $('.Jshoplist .Jshopdelete .JsortList').each(function (i, n) {
            _num = _length - i;
            console.log(_num);
            $(this).parent('.Jshopdelete').find('.sortNum').val(_num);
        })

    })

    var _actName, _ID;
    //搜索商店信息
    $(".Jshoplist").on('blur', ' .act-border .Branch .shopid', function () {
        var _actShopid, _actShopid, _shophtml = ''
        _actShopid = $(this).val();
        var parentNode = $(this).parents(".Jshoplist .act-border");
        if ($.trim(_actShopid)) {
            $.post(getShopUrl, {_actShopid: _actShopid}, function (data) {
                console.log(data);
                if (data.code == 0) {
                    _shophtml += '<div class="control-group">';
                    $.each(data.data.list, function (key, value) {
                        _shophtml += '<option class="Jshopname" data-shopid="' + value.ShopID + '" data-CityAreaID="' + value.CityAreaID + '" data-city="' + value.City + '">' + value.ShopName + '</option>';
                    })
                    _shophtml += ' </div>';
                    parentNode.find('.Branchlist').html(_shophtml);
                }
            }, 'json')
        }
    })

    //是否显示指定日期
    $("input[type=radio][name=BookDate]").change(function(){
        if($(this).val()==2){
            $('.sureDate').removeAttr('disabled');
        }else{
            $('.sureDate').attr('disabled',true);
            $('.sureDate').val('');
        }
    })
    //点击商铺名称
    $('.Jshoplist').on('click', '.act-border .Branchlist .Jshopname ', function () {
        var obj = $(this);
        var parentShopNode = obj.parents(".Branch");
        parentShopNode.find('.shopid').val(obj.text());
        parentShopNode.find('.shopid').attr('shopid', obj.data('shopid'));
        parentShopNode.find('.shopid').attr('cityid', obj.data('city'));
        var shopid = parentShopNode.find('.shopid').attr('shopid');
        var parentNode = obj.parents('.act-border');
        console.log(parentNode);
        $.post(getShopService, {shopid: shopid}, function (data) {
            console.log(data);
            console.log(data.Services);
            var str = data.Services;
            var p = _n - 1;
            if (str.indexOf("1") >= 0 && str.indexOf("6") >= 0) {
                parentNode.find(".radioOne").removeAttr("disabled");
                parentNode.find(".radioSix").removeAttr("disabled");
                parentNode.find(".shop-follow").addClass('radioOneBlack');
                parentNode.find(".shop-book").addClass('radioSixBlack');
                parentNode.find(".radioOne").prop('checked', '');
                parentNode.find(".radioSix").prop('checked', '');
            } else if (str.indexOf("1") >= 0) {
                parentNode.find(".radioOne").removeAttr("disabled");
                parentNode.find(".radioOne").prop('checked', true);
                parentNode.find(".shop-follow").addClass('radioOneBlack');
                parentNode.find(".shop-book").removeClass('radioSixBlack');
                parentNode.find(".radioSix").prop('checked', false);
                parentNode.find(".radioSix").attr("disabled", true);
                parentNode.removeClass('shop-follow');
            } else if (str.indexOf("6") >= 0) {
                parentNode.find(".radioSix").removeAttr("disabled");
                parentNode.find(".radioSix").prop('checked', true);
                parentNode.find(".shop-book").addClass('radioSixBlack');
                parentNode.find(".shop-follow").removeClass('radioOneBlack');
                parentNode.find(".radioOne").prop('checked', false);
                parentNode.find(".radioOne").attr("disabled", true);
                parentNode.removeClass('shop-follow');
            } else {
                parentNode.find(".radioOne").attr("disabled", true);
                parentNode.find(".radioSix").attr("disabled", true);
                parentNode.find(".radioSix").prop('checked', false);
                parentNode.find(".radioOne").prop('checked', false);
                parentNode.find(".shop-follow").removeClass('radioOneBlack');
                parentNode.find(".shop-book").removeClass('radioSixBlack');
            }
        }, 'json')
    })

    //如果排队和预约都有且为空
    $('.Jshoplist').on('change', '.act-border .radioType', function () {
        console.log($(this).val());
    })


    //添加数据
    $(".Jsubmit").click(function () {
        var _shopImg;
        var shop = [];
        var _length = $('.Jshoplist .act-border').length;
        _actName = $.trim($("input[name=Name]").val());
        if (!_actName) {
            standardTips('活动标题不能为空', 2);
            return false;
        }
        _shopImg = $(".image").val();  //图片
        if (!_shopImg) {
            standardTips('请上传活动图片', 2);
            return false;
        }
        //预定信息显示
        var bookdate = $("input[type=radio][name=BookDate]:checked").val();
        if (bookdate == 2) {
            bookdate = $('.sureDate').val();
            if (!bookdate) {
                standardTips('请选择指定时间');
                return false;
            }
        }
        //更多餐厅设置
        var moreShop = $(".more-shop").find("option:selected").val();
        //商家信息
        var flag = true;
        var sort = [];
        if (_length > 0) {
            $(".Jshoplist .act-border").each(function (i, n) {
                $(n).each(function (a,b) {
                    var stack = {};
                    if(!$.trim($(n).find('.sort-info:eq(' + a + ')').val())){
                        standardTips('排序不能为空');
                        flag = false;
                        return false;
                    }
                    sort.push($.trim($(n).find('.sort-info:eq(' + a + ')').val()));

                    if($(n).find('.shopid:eq(' + a + ')').attr('shopid')=='undefined' || !$(n).find('.shopid:eq(' + a + ')').attr('shopid')){
                        standardTips('商家分店不能为空');
                        flag = false;
                        return false;
                    }
                    if(!$.trim($(n).find('.shoptitle:eq(' + a + ')').val())){
                        standardTips('商家文案标题不能为空');
                        flag = false;
                        return false;
                    }

                    var tags = $.trim($(n).find('.shopTag:eq(' + a + ')').val());
                    if(tags&&tags.length>60){
                        standardTips('标签不能大于60个字符');
                        flag = false;
                        return false;
                    }
                    if(!$(n).find('.shoppic:eq(' + a + ')').val() || $(n).find('.shoppic:eq(' + a + ')').val()=='undefined'){
                        standardTips('请上传店铺图片！');
                        flag = false;
                        return false;
                    }

                    if(!$(n).find('input[type=radio]:checked:eq(' + a + ')').val()){
                        standardTips('请选择业务类型', 2);
                        flag = false;
                        return false;
                    }
                    stack.sort = $(n).find('.sort-info:eq(' + a + ')').val();  //排序
                    stack.shopid = $(n).find('.shopid:eq(' + a + ')').attr('shopid'); //商户id
                    stack.cityid = $(n).find('.shopid:eq(' + a + ')').attr('cityid');  //城市id
                    stack.shopname = $(n).find('.shopid:eq(' + a + ')').val();   //商户名称
                    stack.shoptitle = $(n).find('.shoptitle:eq(' + a + ')').val();  //文案
                    stack.shopdesc = $(n).find('.shopdesc:eq(' + a + ')').val();  //描述
                    stack.shoptag = $(n).find('.shopTag:eq(' + a + ')').val();  //标签
                    stack.shoppic = $(n).find('.shoppic:eq(' + a + ')').val();  //图片
                    stack.shoptype = $(n).find('input[type=radio]:checked:eq(' + a + ')').val(); //业务类型
                    shop.push(stack);
                });
            })
        } else {
            standardTips('请添加店铺');
            return false;
        }

        //排序数字不能重复
        var len,newLen;
        len = sort.length;
        newLen = $.unique(sort).length;
        if(len!=newLen){
            standardTips('排序不能重复');
            return false;
        }
        console.log(shop);
        if (!flag) {
            return false;
        }
        //其他专题入口链接
        var linkurl = [];
        var flagUrl = true;
        var linkLength = $('.specialInfo').find('.Jspeclist .act-special').length;
        if(linkLength>0){
            $('.act-special').each(function (j,k) {
                $(k).each(function(x,y){
                    var stackUrl = {};
                    if (!$(k).find('.coverbiglinkFormImg a:eq('+x+')').length || !$(k).find('.coverbiglinkFormImg a:eq('+x+')').attr('href')) {
                        flagUrl = false;
                        standardTips('请上传大图');
                        return false
                    }
                    if (!$(k).find('.coverSmalllinkFormImg a:eq('+x+')').length || !$(k).find('.coverSmalllinkFormImg a:eq('+x+')').attr('href')) {
                        flagUrl = false;
                        standardTips('请上传小图');
                        return false
                    }
                    if ($.trim($(k).find('.linkUrl:eq('+x+')').val()) == '') {
                        flagUrl = false;
                        standardTips('链接不能为空');
                        return false
                    }
                    var rg = /(https?|http):\/\/([^\.\/]+)([\.]?)([^\.\/]+)([\.]?)([^\.\/]+)(\/[\w\-\.\/\?\%\&\=]*)?/i;
                    if ($(k).find('.linkUrl:eq('+x+')').val() && !rg.test($(k).find('.linkUrl:eq('+x+')').val())) {
                        flagUrl = false;
                        standardTips('url格式错误');
                        return false;
                    }
                    stackUrl.bigpic =$(k).find('.coverbiglinkFormImg a:eq('+x+')').data('image'); //大图
                    stackUrl.smallpic =$(k).find('.coverSmalllinkFormImg a:eq('+x+')').data('image'); //小图
                    stackUrl.linkurl =$(k).find('.linkUrl:eq('+x+')').val(); //url
                    linkurl.push(stackUrl);
                })
            })
            if (!flagUrl) {
                return false;
            }
        }
        var data = {
            ActName: _actName,
            ShopImg: _shopImg,
            Shop: shop,
            linkurl: linkurl,
            bookdate: bookdate,
            moreShop: moreShop
        };
        console.log(data);
        $.post(url, data, function (data) {
            console.log(data);
            if (data.errno == 0) {
                standardTips('添加成功');
                window.location.href = viewShop + "&id=" + data.data.ActivityID;
            } else {
                standardTips(data.errmsg);
                return false;
            }
        }, 'json')
    })

    //编辑活动信息
    $('.JsaveActivity').click(function () {
        _ID = $(".act_all").data("shopid");
        var _actName2 = $.trim($(".activityName").val());
        if (!_actName2) {
            standardTips('标题不能为空', 2);
            return false;
        }
        //预定信息显示
        var bookdate = $("input[type=radio][name=BookDate]:checked").val();
        if (bookdate == 2) {
            bookdate = $('.sureDate').val();
            if (!bookdate) {
                standardTips('请选择指定时间');
                return false;
            }
        }
        //更多餐厅设置
        var moreShop = $(".more-shop").find("option:selected").val();
        var _img = $('.actshoppic').val();
        var data = {id: _ID, actName: _actName2, img: _img, bookdate: bookdate, moreShop: moreShop};
        $.post(editActivityUrl, data, function (data) {
            if (data.errno == 0) {
                standardTips('修改成功');
                window.location.reload();
            } else {
                standardTips(data.errmsg);
            }
        }, 'json')
    })


    //加载更多
    var page = 2;
    $('.JMoreActivity').click(function () {
        var _html = '', _type = $('.act_all').data('type');
        $.ajax({
            url: getMoreActicityUrl,
            type: 'post',
            data: {Page: page, Typeid: _type},
            timeout: 15000,
            dataType: "json",
            beforeSend: function (XMLHttpRequest) {
                $(".JMoreActivity").html("加载中……");
            },
            success: function (data, textStatus) {
                if (data.errno == 0) {
                    if (data.data.list.list.length > 0) {
                        $.each(data.data.list.list, function (key, val) {
                            _html += '<tr>' +
                                '<td><input type="checkbox" data-id=""></td>' +
                                '<td>' + val.IDNew + '</td>' +
                                '<td class="act-name">' + val.Name + '<a class="act-view" href="' + getViewUrl + '&id=' + val.ID + '"></a></td>' +
                                '<td>' + val.Type + '</td>' +
                                '<td>' + val.AddTime + '</td>' +
                                '<td>' + val.UpdateTime + '</td>' +
                                '<td>' + val.total + '个链接 <a href="javascript:void(0)" class="Jcopy" data-href="">（查看链接）</a>';
                            if (val.shopdetail) {
                                $.each(val.shopdetail, function (ke, va) {
                                    console.log(ke);
                                    _html += ' <input type="hidden" data-city="' + ke + '" value="' + va.url + '" class="shop-url">';
                                })
                            }
                            _html += '</td>';
                            _html += '</tr>';
                        })
                        $('.Joperate tbody').append(_html);
                        $(".JMoreActivity").html("加载更多活动");
                    } else {
                        $('.JMoreActivity').text('没有更多数据……');
                    }

                }
            },
            complete: function (XMLHttpRequest, textStatus) {
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $(".JMoreActivity").html('加载失败,<a href="javascript:void(0)" class="JMoreActivity">点击重试</a>');
            }
        });
        page++;
    });

    ////首页列表查看
    $(".Joperate tbody").on('mouseenter', 'tr', function () {
        var html = '<span class="Jview" title="查看">查看</span>';
        $(this).find(".act-view").html(html);
    });

    $(".Joperate tbody").on('mouseleave', 'tr', function () {
        $(this).find(".act-view").html('');
    });

    //删除店铺
    $('.table-list').on('click', '.Jsubdel', function () {
        var obj, _id;
        obj = $(this);
        _id = obj.data('id');
        standardConfirm('确认删除', function () {
            $.post(delBusiness, {id: _id}, function (data) {
                if (data.errno==0) {
                    standardTips('删除成功', 2)
                    location.reload();
                }else{
                    standardTips(data.errmsg, 2)
                    return false;
                }
            }, 'json')
        })
    })


    //复制链接
    $(".Joperate").on('click', '.Jcopy', function () {

        var _url = [], _obj = $(this), _city = [], _data = '';
        _obj.parent('td').find('input').each(function (i, n) {
            _url.push($(this).val());
            _city.push($(this).data('city'));
        })

        for (i = 0; i < _url.length; i++) {
            _data += _city[i] + ':' + _url[i] + '<br/>';
        }

        standardAllow(_data, function () {

        });
    });


    //2016092917 modify wuxiang

    //是否显示预约时间
    $('.special-type').change(function () {
        var val = $(this).val();
        if (val == 1) {
            $('.orderDate').css('display', "block");
        } else {
            $('.orderDate').css('display', "none");
        }
    })

})


//获取图片的文章 @1.png
function checkPic(path) {
    var path1 = path.lastIndexOf("\\");
    var name = path.substring(path1 + 1);
    return name;
}

//上传封面
function coverImgChange(obj) {
    var file = $(obj).val();
    if (!file) {
        return false;
    }
    $(obj).parents('#coverImgInfo').find("#imgForm").ajaxSubmit({
        dataType: 'json',
        beforeSubmit: function () {
            $(obj).parents("#coverImgInfo").find("#coverShopImg").html('上传中……');
        },
        success: function (data) {
            if (data.res == 0) {
                $(obj).parents("#coverImgInfo").find("#coverShopImg").html('<a target="_blank" href=' + IMG_URL + data.info + '>预览</a>');
                $(obj).parents("#coverImgInfo").find(".shoppic").val(data.info);
                standardTips('上传成功！');
            } else {
                alert(data.error);
            }
        }
    });


}

//编辑活动图片
function coverActivityChange(obj) {
    var file = $(obj).val();
    if (!file) {
        return false;
    }
    $("#imgFormPic").ajaxSubmit({
        dataType: 'json',
        beforeSubmit: function () {
            $("#coverActImg").html('上传中……');
        },
        success: function (data) {
            console.log(data);
            if (data.res == 0) {
                $("#coverActImg").html('<a target="_blank" href=' + IMG_URL + data.info + '>预览</a>');
                $(obj).parents("#coverImgInfo").find(".actshoppic").val(data.info);
                $(obj).parents(".form-horizontal").find(".editBusPic img").attr('src', IMG_URL + data.info);
                standardTips('上传成功！');
            } else {
                alert(data.error);
            }
        }
    });
}

//房大图片
function getPicSize(img) {
    art.dialog({
        width: '50%',
        height: '50%',
        lock: true,
        content: [
            '<div class="img_left"><img src="' + img + '" id="target"/>',
            '</div>',

        ].join('')
    });
}

function actcoverImgChange(obj) {
    var file = $(obj).val();
    if (!file) {

        return false;
    }
    $("#actimgForm").ajaxSubmit({
        dataType: 'json',
        beforeSubmit: function () {
            $("#coverActImg").html('上传中……');
        },
        success: function (data) {
            if (data.res == 0) {
                $("#coverActImg").html('<a target="_blank" href=' + IMG_URL + data.info + '>预览</a>');
                $(obj).parents("#actcoverImgInfo").find(".image").val(data.info);
                standardTips('上传成功', 2);
            } else {
                alert(data.error);
            }
        },
    });
}


function actcoverImgLink(obj) {
    var file = $(obj).val();
    if (!file) {

        return false;
    }
    $(".linkForm").ajaxSubmit({
        dataType: 'json',
        beforeSubmit: function () {
            $(obj).parents('.linkForm').find(".coverlinkFormImg").html('上传中……');
        },
        success: function (data) {
            if (data.res == 0) {
                $(obj).parents('.linkForm').find(".coverlinkFormImg").html('<a target="_blank" href=' + IMG_URL + data.info + ' data-image=' + data.info + '>预览</a>');
                standardTips('上传成功', 2);
            } else {
                alert(data.error);
            }
        },
    });
}


function coverImgChangeBigLink(obj, type) {
    var file = $(obj).val();
    if (!file) {
        return false;
    }
    $(obj).parents('.coverBigImgInfo').find(".setBigLinkForm").ajaxSubmit({
        dataType: 'json',
        beforeSubmit: function () {
            $(obj).parents('.coverBigImgInfo').find(".coverbiglinkFormImg").html('上传中……');
        },
        success: function (data) {
            if (data.res == 0) {
                if (type) {
                    $(obj).parents('.act-border').find(".bigPic").attr('src', IMG_URL + data.info);
                    $(obj).parents('.coverBigImgInfo').find(".coverbiglinkFormImg").html('<input type="hidden" class="bigPicInfo" value=' + data.info + '><a target="_blank" href=' + IMG_URL + data.info + ' data-image=' + data.info + '>预览</a>');
                } else {
                    $(obj).parents('.coverBigImgInfo').find(".coverbiglinkFormImg").html('<a target="_blank" href=' + IMG_URL + data.info + ' data-image=' + data.info + '>预览</a>');
                }
                standardTips('上传成功', 2);
            } else {
                alert(data.error);
            }
        },
    });
}

function coverImgChangeSmallLink(obj, type) {
    var file = $(obj).val();
    if (!file) {

        return false;
    }
    $(obj).parents('.coverSmallImgInfo').find(".setSmallLinkForm").ajaxSubmit({
        dataType: 'json',
        beforeSubmit: function () {
            $(obj).parents('.coverSmallImgInfo').find(".coverSmalllinkFormImg").html('上传中……');
        },
        success: function (data) {
            if (data.res == 0) {
                if (type) {
                    $(obj).parents('.act-border').find(".smallPic").attr('src', IMG_URL + data.info);
                    $(obj).parents('.coverSmallImgInfo').find(".coverSmalllinkFormImg").html('<input type="hidden" class="smallPicInfo" value=' + data.info + '><a target="_blank" href=' + IMG_URL + data.info + ' data-image=' + data.info + '>预览</a>');
                } else {
                    $(obj).parents('.coverSmallImgInfo').find(".coverSmalllinkFormImg").html('<a target="_blank" href=' + IMG_URL + data.info + ' data-image=' + data.info + '>预览</a>');
                }
                standardTips('上传成功', 2);
            } else {
                alert(data.error);
            }
        },
    });
}


function delPicInfo(obj) {
    var _obj = $(obj);
    _obj.parents('#actcoverImgInfo').find('.view-pic').attr('onclick', '');
    _obj.parents('#actcoverImgInfo').find('.image').val('');
    $("#file_upload").val('');
    $(".acthandle").fadeOut();
    $("#file_upload").show();
    $('.requied-res').show();
}

//验证名称
//function checkName(name, type) {
//    var myReg = /^[0-9A-Za-z\u4e00-\u9fa5]{1,20}$/;
//    if (!myReg.test(name)) {
//        standardTips('请添加话题活动,字数控制在20字符之内', 2);
//        return false
//    }
//}






